<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="4" :lg="4" :md="4" :sm="24">
            <a-form-item label="设备编号">
              <a-input placeholder="请输入设备编号" v-model="queryParam.devSn"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="8" :lg="6" :md="6" :sm="24">
            <a-form-item label="识别时间">
              <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="queryParam.authTime_begin"></j-date>
              <span class="query-group-split-cust"></span>
              <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="queryParam.authTime_end"></j-date>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
<!--          <template v-if="toggleSearchStatus">-->
            <a-col :xl="4" :lg="4" :md="4" :sm="24">
              <a-form-item label="姓      名">
                <a-input placeholder="请输入姓名" v-model="queryParam.psnName"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="4" :lg="4" :md="4" :sm="24">
              <a-form-item label="身份证号">
                <a-input placeholder="请输入身份证号" v-model="queryParam.psnCardno"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="4" :lg="4" :md="4" :sm="24">
              <a-form-item label="性   别">
                <a-input placeholder="请输入性别" v-model="queryParam.psnGender"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="4" :lg="4" :md="4" :sm="24">
              <a-form-item label="国    籍">
                <a-input placeholder="请输入国籍" v-model="queryParam.psnNat"></a-input>
              </a-form-item>
            </a-col>


<!--          </template>-->
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" @click="handleExportXls('抓拍记录')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">详情</a>
        </span>

      </a-table>
    </div>

    <devices-record-modal ref="modalForm" @ok="modalFormOk"></devices-record-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import DevicesRecordModal from './modules/DevicesRecordModal'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'

  export default {
    name: 'DevicesRecordList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      DevicesRecordModal
    },
    data () {
      return {
        description: '识别记录管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'抓拍人像',
            align:"center",
            scopedSlots: {customRender: 'imgSlot'},
            dataIndex: 'psnFace',
            width: 80
          },
          {
            title:'抓拍时间',
            align:"center",
            dataIndex: 'authTime',
           /* customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            },*/
            width: 100
          },
          {
            title:'姓名',
            align:"center",
            dataIndex: 'psnName',
            width: 100
          },
          {
            title:'性别',
            align:"center",
            dataIndex: 'psnGender_dictText',
            width: 60
          },
          {
            title:'人员类别',
            align:"center",
            dataIndex: 'psnType_dictText',
            width: 100
          },
          {
            title:'国籍',
            align:"center",
            dataIndex: 'psnNat',
            width: 100
          },
          {
            title:'身份证号',
            align:"center",
            dataIndex: 'psnCardno',
            width: 150
          },
          {
            title:'设备名称',
            align:"center",
            dataIndex: 'devName',
            width: 150
          },
          {
            title:'设备编号',
            align:"center",
            dataIndex: 'devSn',
            width: 150
          },
          {
            title:'地址',
            align:"center",
            dataIndex: 'devAddress',
            width: 200
          },
          {
            title:'坐标',
            align:"center",
            dataIndex: 'devLocation',
            width: 150
          },
          {
            title:'方向',
            align:"center",
            dataIndex: 'devDirection',
            width: 100
          },
          {
            title:'自动备注',
            align:"center",
            dataIndex: 'remarks',
            width: 150
          },
          /*{
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }*/
        ],
        /* 分页参数 */
        ipagination: {
          current: 1,
          pageSize: 20,
          pageSizeOptions: ['20', '40', '60'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' 共' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        url: {
          list: "/iot/devicesRecord/list",
          delete: "/iot/devicesRecord/delete",
          deleteBatch: "/iot/devicesRecord/deleteBatch",
          exportXlsUrl: "/iot/devicesRecord/exportXls",
          importExcelUrl: "iot/devicesRecord/importExcel",

        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    props: {
      queryParam: Object,
      queryConfig: Array,
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'authSerial',text:'流水号',dictCode:''})
        fieldList.push({type:'int',value:'authMode',text:'认证方式',dictCode:'auth_mode'})
        fieldList.push({type:'date',value:'authTime',text:'识别时间'})
        fieldList.push({type:'string',value:'authKyq',text:'抗疫情对比结果',dictCode:''})
        fieldList.push({type:'string',value:'psnName',text:'姓名',dictCode:''})
        fieldList.push({type:'int',value:'psnGender',text:'性别',dictCode:''})
        fieldList.push({type:'int',value:'psnType',text:'人员类别',dictCode:'psn_type_in'})
        fieldList.push({type:'int',value:'psnNat',text:'国籍',dictCode:'psn_nationality'})
        fieldList.push({type:'string',value:'psnTemperature',text:'体温',dictCode:''})
        fieldList.push({type:'string',value:'psnFace',text:'图片',dictCode:''})
        fieldList.push({type:'string',value:'psnQrcode',text:'二维码',dictCode:''})
        fieldList.push({type:'string',value:'psnCardno',text:'身份证号',dictCode:''})
        fieldList.push({type:'string',value:'psnCardnum',text:'卡号',dictCode:''})
        fieldList.push({type:'string',value:'prompts',text:'播报内容',dictCode:''})
        fieldList.push({type:'string',value:'devName',text:'设备名称',dictCode:''})
        fieldList.push({type:'string',value:'devSn',text:'设备编号',dictCode:''})
        fieldList.push({type:'int',value:'devType',text:'设备类型',dictCode:'dev_type'})
        fieldList.push({type:'string',value:'devAddress',text:'地址',dictCode:''})
        fieldList.push({type:'string',value:'devLocation',text:'坐标',dictCode:''})
        fieldList.push({type:'string',value:'devDirection',text:'方向',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>